package com.platform.module.common.validator;

import com.platform.module.common.base.CodeEnum;
import com.platform.module.common.base.Phone;
import com.platform.module.common.utils.AssertUtils;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

import java.util.regex.Pattern;

/**
 * 手机号码校验器
 */
public class PhoneConstraintValidator implements ConstraintValidator<Phone, String> {

    static Pattern compile = Pattern.compile("^1\\d{10}$");

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }

        return compile.matcher(value).matches();
    }
}
